<?php
//session_start();

//if (!isset($_SESSION['kid'])) {
    
   // include("startseite.php");
   // exit();
//}

$tischid = $_GET['id'];

require_once("db/connectDB.php");
$tischresult = mysql_query ("SELECT * FROM tische WHERE id= $tischid");
$bestellungssresult = mysql_query ("SELECT * FROM bestellung WHERE tischid= $tischid");

?>

<!DOCTYPE html>
<html lang="de">
  <head>
    <meta charset="utf-8 ">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>gerufentisch</title>
		<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
		<link href="bootstrap/css/style.css" rel="stylesheet">
		<link href="bearbeitung.css" rel="stylesheet">
		<script src="js/jquery-1.11.1.min.js"></script>
		<script src="js/bon.js"></script>
		<script src="bootstrap/js/bootstrap.min.js"></script>
		<script type="text/javascript">
			$( document ).ready(function(){
				//var z=""; //zahl
				//var table_row_index;
				//var menge =[];
				//var gericht = [];
				//var gerichtid=[];
				//var preis = [];
				//var sum=0;
				$( "#w1" ).show();
				$( "#so1" ).hide();
				$( "#ape1" ).hide();			
				$( "#hot1" ).hide();	
				$( "#bw1" ).hide();			
				$( "#ma1" ).hide();			
				$( "#des1" ).hide();
				
				$( "a" ).click(function(){
					choosemeal($(this).text());
												
				});
					
			});
		</script>
	</head>
	<body>
	<div class= "container" style ="background: #123456;">	
		<div class= "jumbotron" style = "background-color: #341256; text-align: center;">
			<p style = "color: white; font-size: 30px;"> Nam Bộ Restaurant</p>
		</div>
	<div class= "row">
			
			<div class= "btn-group  btn-group-justified">
				<?php 
					$rowtr= mysql_fetch_array($tischresult);
				?>
				<a class="btn btn-danger btn-sm btn-block" role="button" style ="font-size: 14px;"><b>Tischnr: <?php echo $rowtr['tischnr'];?></b></a>
			
		
				<a class="btn btn-danger btn-sm btn-block" role="button" style ="font-size: 14px;"><b>Zeit: 
				<?php  
					$dt1= date("d-m-Y H:i:s", strtotime( $rowtr['zeit'] ));
					echo $dt1;
					
				?>
				</b></a>
			
			
				<a class="btn btn-danger btn-sm btn-block" role="button" style ="font-size: 14px;"><b>Kellner: <?php echo $rowtr['kid'];?></b></a>
			
			
				<a class="btn btn-danger btn-sm btn-block" role="button" style ="font-size: 14px;"><b>Gast: <?php echo $rowtr['gast'];?></b></a>
				
			</div>
		</div>
		<br>
	</div>
	<br>
	<div class= "container" style ="background: #123456;">
		<div class= "row">
			<div class="col-xs-6 col-md-4">
				<br>
				<div  id ="scrollarea"  style ="font-size: 15px;  width:350px; height:505px; overflow: auto;background:white;">
					<table class='table'>
					<?php
					
						while ($row = mysql_fetch_array($bestellungssresult)){					
							$gerichtname = mysql_query ('SELECT namev FROM gericht1 WHERE gerichtid ='.$row['gerichtid']);
							$gn = mysql_fetch_array($gerichtname);
							echo $row['gerichtid'];
							echo "<tr class= 'success'><td>".$row['menge']."</td> <td>".$row['gerichtid']."</td></tr>";
						}
					mysql_free_result($tischresult);
					//mysql_free_result($bestellungssresult);*/
					?>
					</table>
				</div>
				
			</div>
			
			<div class=" col-xs-6 col-md-1" >
				<br>
				<z class="btn btn-warning btn-sm btn-block" style ="font-size: 15px;color:#5c0507;">clear</z>				
				<z class="btn btn-warning btn-sm btn-block" style ="font-size: 15px;color:#5c0507;">0</z>
				<z class="btn btn-warning btn-sm btn-block" style ="font-size: 15px; color:#5c0507">1</z>
				<z  class="btn btn-warning btn-sm btn-block" style ="font-size: 15px;color:#5c0507">2</z>
				<z class="btn btn-warning btn-sm btn-block" style ="font-size: 15px;color:#5c0507">3</z>
				<z class="btn btn-warning btn-sm btn-block" style ="font-size: 15px;color:#5c0507">4</z>
				<z class="btn btn-warning btn-sm btn-block" style ="font-size: 15px;color:#5c0507">5</z>
				<z class="btn btn-warning btn-sm btn-block" style ="font-size: 15px;color:#5c0507">6</z>
				<z class="btn btn-warning btn-sm btn-block" style ="font-size: 15px;color:#5c0507">7</z>
				<z class="btn btn-warning btn-sm btn-block" style ="font-size: 15px;color:#5c0507">8</z>
				<z class="btn btn-warning btn-sm btn-block" style ="font-size: 15px;color:#5c0507">9</z>
				<z class="btn btn-warning btn-sm btn-block" style ="font-size: 15px;color:#5c0507">x</z>
				<br>
				
			</div>
			<div class=" col-xs-6 col-md-2">
				<br>
				<a class="btn btn-success btn-lg btn-block" style ="font-size: 15px;"><b>Wasser/Säfte</b><br></a>
				<a class="btn btn-success btn-lg btn-block" style ="font-size: 15px;"><b>Softdrink</b><br></a>
				<a class="btn btn-success btn-lg btn-block" style ="font-size: 15px;"><b>Hotdrink</b><br></a>
				<a class="btn btn-success btn-lg btn-block" style ="font-size: 15px;"><b>Bier/Wein</b><br></a>
				<a class="btn btn-success btn-lg btn-block" style ="font-size: 15px;"><b>Longdrink</b><br></a>
				<a class="btn btn-danger btn-lg btn-block" style ="font-size: 15px;"><b>Vorspeise</b><br></a>
				<a class="btn btn-danger btn-lg btn-block" style ="font-size: 15px;"><b>Hauptspeise</b><br></a>
				<a class="btn btn-danger btn-lg btn-block"  style ="font-size: 15px;"><b>Mittag</b><br></a>
				<a class="btn btn-danger btn-lg btn-block"  style ="font-size: 15px;"><b>Nachspeise</b><br></a>
				<a class="btn btn-info btn-lg btn-block"  style ="font-size: 15px;"><b>Als 1.Gang</b><br></a>
				<a class="btn btn-info btn-lg btn-block"  style ="font-size: 15px;"><b>Als 2.Gang</b><br></a>
				<br>
			</div>
			
			<div class="col-xs-6 col-md-5" style = "background: #341256; overflow:auto;">
				<div id ="fenster2"  style = "background: #341256; text-align: center; height:525px;">
				
					<?php
						require_once("db/connectDB.php");	
						callMeal("w1",115,124);
						callMeal("so1",125,134);
						callMeal("hot1",135,140);
						callMeal("bw1",141,150);
						callMeal("ape1",1,18);
						callMeal("ma1",19,35);
						callMeal("des1",36,41);
					?>
				
				</div>
			</div>
		</div>
	</div>
	<!--/div-->
	<div class= "container" style = "background: #341256;">
		<div class="row">

				<div class=" col-md-12">
					
					
					<a class="btn btn-warning btn-lg tbn-block" style="font-size:25px;">BON<br>SENDEN<br><br></a>
							
					<a class="btn btn-default btn-lg tbn-block" style="font-size:25px;">ZW.<br>Rechnung<br><br></a>
					
					<a class="btn btn-primary btn-lg tbn-block" style="font-size:25px;"><br>ZAHLUNG<br><br></a>
					
					<a class="btn btn-info btn-lg tbn-block" style="font-size:25px;"><br>Funktion<br><br></a>
					
					<a class="btn btn-danger btn-lg tbn-block" style="font-size:25px;"><br>STORNO<br><br></a>
					
					<a  class="btn btn-danger btn-lg tbn-block" style="font-size:25px;"><br>ABBRECHEN<br><br></a>
				</div>
		</div> 
	</div> 
	
	</body>
</html>

<?php

	function callMeal($div, $id1, $id2){
		$j=3;
		$i=0;
		mysql_query("SET NAMES 'utf8'");
		$result =mysql_query("select * from gericht where id >=$id1 and id<=$id2");
		
		echo "<div id = $div >";//$div
		while ($row = mysql_fetch_array($result)){
				
			if($i==0 || $i==$j){
				if($i==$j) {
					$j=3+$j;
				}
				echo "<div  class= 'row'>";// div row
				echo "<div class= 'col-xs-6 col-md-4'>";//zelle
				echo "<w type= 'button' class='btn btn-success btn-lg btn-block' style ='font-size: 15px;'>".$row['named']."</w>";
				echo "</div>";//zelle
				$i++;
			}
				
			else{
				echo "<div class= 'col-xs-6 col-md-4'>";
				echo "<w  type= 'button' class='btn btn-success btn-lg btn-block' style ='font-size: 15px;'>".$row['named']."</w>";
				echo "</div>";
				if($i==($j-1)){
					echo "</div>";//div row
					echo "<br>";
				}
				
				$i++;
			}
		}
		
		$k= $i-1;
		$l= $j-3;
		//check 
		if($k===$l) {
			echo "</div>"; 
		}
		echo "</div>"; // for <div id = $div>
		mysql_free_result($result);	
	}
?>